package com.Controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.imageDao;
import com.moddel.ImageB;
import com.moddel.makeB;

public class bluemsunMake extends HttpServlet {

	public bluemsunMake() {
		super();
	}


	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

	   doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String flag=request.getParameter("flag");
        switch(flag){
               case "selectBluemsunM":{
            	   selectBluemsunM( request,response);
            	   break;
               }
               case "addMake":{
            	   addMake(request, response);
            	   break;
               }
               case "selectMake":{
              	 selectMake(request, response);
              	 break;
               }
        
        }
		
	}
	private static void selectBluemsunM(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		
		imageDao sm=new imageDao();
		ArrayList<ImageB> list_1=new ArrayList<ImageB>();
		ArrayList<makeB> list_2=new ArrayList<makeB>();
		list_1=sm.selectImage();
		list_2=sm.selectAllMake();
		request.setAttribute("list_1", list_1);
		request.setAttribute("list_2", list_2);
		request.getRequestDispatcher("bluemsunMake.jsp").forward(request, response);
		
	}
	private static void addMake(HttpServletRequest request, HttpServletResponse response){
		int id=Integer.parseInt(request.getParameter("makeid"));
		int iid=Integer.parseInt(request.getParameter("makeiid"));
		String makeid=request.getParameter("makeid");
		String makename=request.getParameter("makename");
		String makeImage=request.getParameter("makeImage");
		imageDao addm=new imageDao();
		
	}
	private static void selectMake(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		int pageSize=Integer.parseInt(request.getParameter("pagesize"));
		int pageNow=Integer.parseInt(request.getParameter("pagenow"));
		imageDao sm=new imageDao();
		ArrayList<makeB> list_2=new ArrayList<makeB>();
		list_2=sm.selectAllMake(pageSize,pageNow);
		request.setAttribute("list_2", list_2);
		request.getRequestDispatcher("userPlatform.jsp").forward(request, response);
	}

}
